//
// Created by Administrator on 2021/9/15.
//

#include<stdio.h>
#include<stdlib.h>

int days[]={31,28,31,30,31,30,31,31,30,31,30,31};

int day_of_year(int year,int month,int day){
    days[1] = ((year%4==0&&year%100!=0)||year%400==0)?29:28;
    int doy = 0;
    for(int i=0;i<month;i++){
        doy += days[i];
    }
    doy += day;
    return doy;
}

void month_day(int year,int day,int* pmonth,int* pday){
    days[1] = ((year%4==0&&year%100!=0)||year%400==0)?29:28;
    for(int i=0;i<12;i++){
        day -= days[i];
        if(day<0){
            day += days[i];
            *pmonth = i;
            *pday = day;
            break;
        }
    }
}

int test(){
    int year;
    int month = 9;
    int day = 15;
    scanf("%d %d %d",&year,&month,&day);
    printf("%d\n", day_of_year(year,month,day));
    scanf("%d %d",&year,&day);
    month_day(year,day,&month,&day);
    printf("%d %d\n",month,day);
}